package com.luobr.backend.model.enums;

import cn.hutool.core.util.ObjUtil;
import com.luobr.backend.constant.SpaceConstant;
import lombok.Getter;

@Getter
public enum SpaceLevelEnum {

    COMMON("普通版", 0, 100, SpaceConstant.SPACE_SIZE_LIMIT.COMMON),
    PROFESSIONAL("专业版", 1, 1000, SpaceConstant.SPACE_SIZE_LIMIT.PROFESSIONAL),
    FLAGSHIP("旗舰版", 2, 10000, SpaceConstant.SPACE_SIZE_LIMIT.FLAGSHIP);

    // 文本
    private final String text;
    // 值
    private final int value;
    // 最大图片上传大小
    private final long maxCount;
    // 最大图片上传数量
    private final long maxSize;

    SpaceLevelEnum(String text, int value, long maxCount, long maxSize) {
        this.text = text;
        this.value = value;
        this.maxCount = maxCount;
        this.maxSize = maxSize;
    }

    /**
     * 根据 value 获取枚举
     */
    public static SpaceLevelEnum getEnumByValue(Integer value) {
        if (ObjUtil.isEmpty(value)) {
            return null;
        }
        for (SpaceLevelEnum spaceLevelEnum : SpaceLevelEnum.values()) {
            if (spaceLevelEnum.value == value) {
                return spaceLevelEnum;
            }
        }
        return null;
    }
}
